from datetime import datetime

from django.db import models

# Create your models here.

class Course(models.Model):
    name = models.CharField(max_length=50,verbose_name=u'课程名称')
    desc = models.CharField(max_length=50,verbose_name=u'课程描述')
    detail = models.TextField(verbose_name=u'课程详情')
    degree = models.CharField(max_length=50, choices=(('cj', u'初级'), ('zj', u'中级'), ('gj', u'高级')),
                              verbose_name=u"级别")
    lean_times= models.IntegerField(default=0,verbose_name=u'学习时长')
    students= models.IntegerField(default=0,verbose_name=u'学习人数')
    fav_nums= models.IntegerField(default=0,verbose_name=u'收藏人数')
    click_nums= models.IntegerField(default=0,verbose_name=u'点击数')
    image = models.ImageField(upload_to='uploads/image/%Y/%m',verbose_name=u'封面')
    add_time = models.DateTimeField(default=datetime.now,verbose_name=u'添加时间')

    class Meta:
        verbose_name = u"课程信息"
        verbose_name_plural=verbose_name


class Lesson(models.Model):
    course = models.ForeignKey(Course, verbose_name=u'课程',on_delete=models.DO_NOTHING)
    name = models.CharField(max_length=50, verbose_name=u'章节名称')
    add_time = models.DateTimeField(default=datetime.now, verbose_name=u'添加时间')

    class Meta:
        verbose_name = u"章节信息"
        verbose_name_plural=verbose_name


class Video(models.Model):
    lesson = models.ForeignKey(Lesson, verbose_name=u'课程名称',on_delete=models.DO_NOTHING)
    name = models.CharField(max_length=50, verbose_name=u'课程描述')
    add_time = models.DateTimeField(default=datetime.now, verbose_name=u'添加时间')

    class Meta:
        verbose_name = u"视频信息"
        verbose_name_plural=verbose_name

class CourseResource(models.Model):
    course = models.ForeignKey(Course, verbose_name=u'课程',on_delete=models.DO_NOTHING)
    name = models.CharField(max_length=50, verbose_name=u'章节名称')
    download = models.FileField(upload_to='uploads/course/%Y/%m',verbose_name=u'文件')
    add_time = models.DateTimeField(default=datetime.now, verbose_name=u'添加时间')

    class Meta:
        verbose_name = u"视频信息"
        verbose_name_plural=verbose_name
